<template>
  <div>
    <van-picker
      title="标题"
      show-toolbar
      :columns="columns"
      :default-index="this.gender"
      @confirm="onConfirm"
      @cancel="$emit('closeGenderPup')"
    />
  </div>
</template>

<script>
import { editUserInfo } from '@/api/user'
export default {
  name: 'GenderPup',
  props: {
    gender: {
      type: Number,
      required: true
    }
  },
  data () {
    return {
      columns: ['男', '女']
    }
  },
  methods: {
    async onConfirm (val, i) {
      await editUserInfo({
        gender: i
      })
      this.$toast.success('修改性别成功')
      this.$emit('editGender', i)
    }
  }
}
</script>

<style></style>
